package com.nfdw.project.enums;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.Getter;
import lombok.Setter;

import java.util.Arrays;
import java.util.Optional;
import java.util.stream.IntStream;

import static java.util.Locale.filter;

@Getter
@AllArgsConstructor
public enum CompanyTypeEnum {

    STATE_OWNED_ENTERPRISES("01","国有企业"),
    PRIVATE_ENTERPRISES("02","民营企业"),
    COLLECTIVE_ENTERPRISES("03","集体企业"),
    THREE_FUNDED_ENTERPRISES("04","三资企业"),
    ;

    String companyType;

    String companyName;

    public static String getCompanyTypeByIndex(Integer index){
        return CompanyTypeEnum.values()[index].getCompanyType();
    }

    public static Integer findIndex(String companyType){
        int index = IntStream.range(0, CompanyTypeEnum.values().length-1)
                .filter(i -> CompanyTypeEnum.values()[i].getCompanyType().equals(companyType))
                .findFirst()
                .orElse(-1);
        return index;
    }
}
